home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / gg243774.zip / PWFOLDER.ZIP / PWFOLDER.CSC < prev    next >
Text File  |  1992-04-03  |  8KB  |  270 lines

  1. ##########################################################
  2. #                                                        #
  3. #  PWFOLDER.CSC          (c) IBM Corporation 1992        #
  4. #                                                        #
  5. #  This class derives from WPFolder, and is used to      #
  6. #  represent a folder which is protected by a password.  #
  7. #                                                        #
  8. ##########################################################
  9.  
  10. #
  11. # Include the class definition file for the parent class
  12. #
  13. include <wpfolder.sc>
  14.  
  15. #
  16. #   Define the new class
  17. #
  18. class: PWFolder,
  19.        file stem = pwfolder,
  20.        external prefix = pwfolder_,
  21.        class prefix = pwfoldercls_,
  22.        major version = 1,
  23.        minor version = 1,
  24.        local;
  25.  
  26. -- PWFolder is a Password protected folder.
  27. -- It is derived as follows:
  28. --        SOMOject
  29. --          - WPObject
  30. --             - WPFileSystem
  31. --                - WPFolder
  32. --                   - PWFolder
  33.  
  34. #
  35. # Specify the parent class
  36. #
  37. parent: WPFolder;
  38.  
  39. #
  40. # Specify the release order of new methods
  41. #
  42. release order: LockFolder;
  43.  
  44. #
  45. # Passthru a debug message box to the .ih file
  46. # (for inclusion in the .c file)
  47. #
  48. passthru: C.h, after;
  49.  
  50. #define DebugBox(title, text)  WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, \
  51.                                (PSZ) text , (PSZ) title, 0, \
  52.                                MB_OK | MB_INFORMATION )
  53.  
  54. endpassthru;
  55.  
  56. #
  57. # Passthru private definitions to the .ph file
  58. # (for inclusion in the .c file)
  59. #
  60. passthru: C.ph;
  61.  
  62. typedef struct _PWF_INFO {                       /* Define password structure */
  63.   CHAR   szPassword[20];                         /* Folder current password   */
  64.   CHAR   szCurrentPassword[20];                  /* User-entered password     */
  65.   CHAR   szUserid[20];                           /* Userid                    */
  66. } PWF_INFO;
  67. typedef PWF_INFO *PPWF_INFO;                     /* Define pointer type       */
  68.  
  69. endpassthru;
  70.  
  71. #
  72. # Define instance data for the class
  73. #
  74. data:
  75. CHAR szPassword[20];
  76. --  This is the password which locks the folder
  77.  
  78. CHAR szCurrentPassword[20];
  79. --  This is the password the user has typed in to be
  80. --  checked against the lock password
  81.  
  82. CHAR szUserid[20];
  83. --  Userid
  84.  
  85. #
  86. # Define new methods
  87. #
  88. methods:
  89.  
  90. BOOL QueryInfo(PPWF_INFO pPWFolderInfo), private;
  91. --
  92. --  METHOD:   QueryInfo                                   PRIVATE
  93. --
  94. --  PURPOSE:  Copies instance data into the PWF_INFO structure.
  95. --
  96. --  INVOKED:  From PasswordDlgProc
  97. --
  98.  
  99. BOOL SetInfo(PPWF_INFO pPWFolderInfo), private;
  100. --
  101. --  METHOD:   SetInfo                                     PRIVATE
  102. --
  103. --  PURPOSE:  Sets instance data from the PWF_INFO structure.
  104. --
  105. --  INVOKED:  From PasswordDlgProc
  106. --
  107.  
  108. BOOL LockFolder();
  109. --
  110. --  METHOD:   LockFolder                                  PUBLIC
  111. --
  112. --  PURPOSE:  Invalidates the current password, thereby locking the folder.
  113. --
  114. --  INVOKED:  From _wpMenuItemSelected
  115. --
  116.  
  117. #
  118. # Specify methods being overridden
  119. #
  120. override wpInitData;
  121. --
  122. --  METHOD:   wpInitData                                  PUBLIC
  123. --
  124. --  PURPOSE:  Initializes instance data
  125. --
  126. --  INVOKED:  By Workplace Shell, upon instantiation of the object instance.
  127. --
  128.  
  129. override wpModifyPopupMenu;
  130. --
  131. --  METHOD:   wpModifyPopupMenu                           PUBLIC
  132. --
  133. --  PURPOSE:  Adds an additional "Lock" item to the object's context menu.
  134. --
  135. --  INVOKED:  By Workplace Shell, upon instantiation of the object instance.
  136. --
  137.  
  138. override wpMenuItemSelected;
  139. --
  140. --  METHOD:   wpMenuItemSelected                          PUBLIC
  141. --
  142. --  PURPOSE:  Processes the user's selections from the context menu.  The
  143. --            overridden method processes only the added "Lock" item, before
  144. --            invoking the parent's default processing to handle other items.
  145. --
  146. --  INVOKED:  By Workplace Shell, upon selection of a menu item by the user.
  147. --
  148.  
  149. override wpOpen;
  150. --
  151. --  METHOD:   wpOpen                                      PUBLIC
  152. --
  153. --  PURPOSE:  Only allows a folder to be opened if the folder is unlocked, or
  154. --            if the user supplies the correct password in response to the
  155. --            dialog.
  156. --
  157. --  INVOKED:  By Workplace Shell, upon selection of the "Open" menu item by
  158. --            the user.
  159. --
  160.  
  161. override wpSetTitle;
  162. --
  163. --  METHOD:   wpSetTitle                                  PUBLIC
  164. --
  165. --  PURPOSE:  Sets the folder's title (icon text) to have the phrase <Locked>
  166. --            as a suffix if the folder is locked, or removes this suffix if
  167. --            the folder is unlocked.
  168. --
  169. --  INVOKED:  By wpOpen to set the unlocked state, and by LockFolder to set
  170. --            the locked state.
  171. --
  172.  
  173. override wpSetup;
  174. --
  175. --  METHOD:   wpSetup                                     PUBLIC
  176. --
  177. --  PURPOSE:  Sets folder properties based upon a setup string passed by the
  178. --            object's creator as part of the WinCreateObject() call.  The
  179. --            overridden method simply processes the PASSWORD keyword to set
  180. --            the folder's password immediately upon instantiation, before
  181. --            invoking the parent's default processing to handle all other
  182. --            keywords.
  183. --
  184. --  INVOKED:  By the Workplace Shell, upon instantiation of the object
  185. --            instance.
  186. --
  187.  
  188. override wpSaveState;
  189. --
  190. --  METHOD:   wpSaveState                                 PUBLIC
  191. --
  192. --  PURPOSE:  Saves the object instance's persistent state data.  The
  193. --            overridden method simply saves the password data, then invokes
  194. --            the parent's default processing to handle any other instance
  195. --            data defined by ancestor classes.
  196. --
  197. --  INVOKED:  By the Workplace Shell, when the object becomes dormant.
  198. --
  199.  
  200. override wpRestoreState;
  201. --
  202. --  METHOD:   wpRestoreState                              PUBLIC
  203. --
  204. --  PURPOSE:  Restores the object instance's persistent state data.  The
  205. --            overridden method simply restores the password data, then
  206. --            invokes the parent's default processing to handle any other
  207. --            instance data defined by ancestor classes.
  208. --
  209. --  INVOKED:  By the Workplace Shell, when the object becomes awake.
  210. --
  211.  
  212. override wpSetIcon;
  213. --
  214. --  METHOD:   wpSetIcon                                   PUBLIC
  215. --
  216. --  PURPOSE:  This class method returns the handle to the correct icon for
  217. --            the object.
  218. --
  219. --  INVOKED:  -
  220. --
  221.  
  222. override wpclsQueryTitle, classmethod;
  223. --
  224. --  METHOD:   wpclsQueryTitle                             PUBLIC
  225. --
  226. --  PURPOSE:  This class method returns the default folder title for any
  227. --            instance of the password protected folder class.  This title
  228. --            is used if a title is not supplied in the WinCreateObject()
  229. --            call.
  230. --
  231. --  INVOKED:  By the Workplace Shell, upon instantiation of the object
  232. --            instance.
  233. --
  234.  
  235. override wpclsInitData, classmethod;
  236. --
  237. --  METHOD:   wpclsInitData                               PUBLIC
  238. --
  239. --  PURPOSE:  This class method allows the initialization of any class data
  240. --            items.  The overridden method simply obtains a module handle
  241. --            to be used when accessing Presentation Manager resources, then
  242. --            invokes the parent's default processing.
  243. --
  244. --  INVOKED:  By the Workplace Shell, upon loading the class DLL.
  245. --
  246.  
  247. override wpclsQueryIcon, classmethod;
  248. --
  249. --  METHOD:   wpclsQueryIcon                                 PUBLIC
  250. --
  251. --  PURPOSE:  This class method returns the handle to the default icon for
  252. --            the class.  This method is not used in the current version,
  253. --            but could be used if different icons are to be used for the
  254. --            locked and unlocked states.
  255. --
  256. --  INVOKED:  -
  257. --
  258.  
  259. override wpclsUnInitData, classmethod;
  260. --
  261. --  METHOD:   wpclsUnInitData                             PUBLIC
  262. --
  263. --  PURPOSE:  This class method allows the release of any class data items
  264. --            or resources.  The overridden method releases the module handle
  265. --            obtained by wpclsInitData, then invokes the parent's default
  266. --            processing.
  267. --
  268. --  INVOKED:  By the Workplace Shell, upon unloading the class DLL.
  269. --
  270.